//
//  changeNewPhoneVC.m
//  BeautyPicture
//
//  Created by 沈振邦 on 15/12/2.
//  Copyright © 2015年 szb. All rights reserved.
//

#import "changeNewPhoneVC.h"
#import "MBProgressHUD+MJ.h"
#import "AccountTool.h"
#import "BPhttpTool.h"

@interface changeNewPhoneVC ()
@property (nonatomic,strong,readonly)UIView *headView;
@end

@implementation changeNewPhoneVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.passWord.placeholder = @"请输入以前使用的密码";
    self.phoneNmuber.placeholder = @"请输入新手机号";
    [self.changePass setTitle:@"更改手机" forState:UIControlStateNormal];
    self.navigationController.navigationBarHidden = NO;
    
    // Do any additional setup after loading the view.
}




- (void)changePassOrNewPhone
{
    if ([self.message.text isEqualToString:@""]) {
        [MBProgressHUD showError:@"验证码不能为空"];
        return;
    }
    if (![self.message.text isEqualToString:self.paramAccount.verifycode]) {
        [MBProgressHUD showError:@"验证码错误"];
        return;
    }

    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    [param setValue:@"mobile" forKey:@"field"];
    [param setValue:self.passWord.text forKey:@"password"];
    [param setValue:self.phoneNmuber.text forKey:@"value"];
    [param setValue:[AccountTool account].uid forKey:@"uid"];
    
    [BPhttpTool post:[NSString stringWithFormat:@"%@user/updateInfo",BPhttp] params:param success:^(id responseObj) {
        NSDictionary *dic = responseObj;
        if ([dic[@"info"] intValue] == -11) {
            [MBProgressHUD showError:@"手机号相同"];
        }else if ([dic[@"status"] intValue] == 0){
            [MBProgressHUD showError:@"密码错误"];
        }else if ([dic[@"status"] intValue] == 1){
            [MBProgressHUD showSuccess:@"修改成功"];
            _block(self.phoneNmuber.text);
            [self.navigationController popViewControllerAnimated:YES];
        }
    } failure:^(NSError *error) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
